<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <title>用户登录页</title>
    <link rel="stylesheet" href="/css/bootstrap.min.css">
    <script src="/js/jquery-3.7.1.min.js"></script>
    <script src="/js/bootstrap.min.js"></script>
    <!-- 登录页CSS样式 -->
    <style>
        body {
            background-color: #f0f0f0; /* 页面背景色 */
        }
        .container-fluid {
            padding: 20px; /* 容器内边距 */
        }
        .panel {
            background-color: #fff; /* 面板背景色 */
            border: 1px solid #ddd; /* 面板边框 */
            border-radius: 5px; /* 边框圆角 */
            box-shadow: 0 0 10px rgba(0,0,0,0.1); /* 阴影 */
            margin-top: 80px; /* 顶部外边距 */
            width: 350px;
            height: 350px;
            margin-left: 450px;
        }
        .panel-heading {
            background-color: #0cbeff; /* 标题背景色 */
            color: #fff; /* 标题文字颜色 */
            text-align: center;
            font-size: 20px;
            padding: 10px; /* 标题内边距 */
            border-bottom: 1px solid #ddd; /* 标题底部边框 */
            border-top-left-radius: 5px; /* 左上角圆角 */
            border-top-right-radius: 5px; /* 右上角圆角 */
        }
        .panel-body {
            display: flex;
            flex-direction: column;
            align-items: center;
            justify-content: center;
            margin-top: 35px;
        }
        form {
            display: flex;
            flex-direction: column;
            width: 80%;
        }
        .form-group {
            margin-bottom: 20px; /* 表单项之间的间距 */
        }
        .form-group label {
            display: block; /* label单独一行 */
            margin-bottom: 5px; /* label与input之间的间距 */
        }
        .btn-default {
            width: 80px;
            background-color: #0cbeff; /* 按钮背景色 */
            border-color: #0ca2ff; /* 按钮边框色 */
            color: #fff; /* 按钮文字颜色 */
            padding: 10px; /* 内边距 */
            border-radius: 5px; /* 圆角 */
            cursor: pointer; /* 鼠标悬停时显示小手图标 */
            margin-left: 90px;
            margin-top: 25px;
        }
        .btn-default:hover {
            background-color: #0c86ff; /* 鼠标悬停时按钮背景色 */
            border-color: #0c7dff; /* 鼠标悬停时按钮边框色 */
        }
    </style>
    <link rel="stylesheet" href="/plugins/bootstraptable/bootstrap-table.min.css">
</head>

<body>
<div class="container-fluid">
    <div class="panel panel-default">
        <div class="panel-heading">账号登录</div>
        <div class="panel-body">
            <form>
                <div class="form-group">
                    <label for="username">用户名：</label>
                    <input type="text" class="form-control" id="username" name="username" placeholder="用户名">
                </div>
                <div class="form-group">
                    <label for="password">密码：</label>
                    <input type="password" class="form-control" id="password" name="password" placeholder="密码">
                </div>
                <button type="button" class="btn btn-default" onclick="login();">登录</button>
            </form>
        </div>
    </div>
</div>

<script type="text/javascript">
    function login() {
        var name=$("#username").val();
        var password=$("#password").val();
        $.ajax({
            url:"/api/login/user",
            data:{
                username:name,
                password:password
            }
        }).done(function (rs) {
            if(rs>=0){
                window.location.href="/student/list";
            }else{
                alert("出错了，您的用户名或密码错误！");
            }
        });
    }
</script>
</body>
</html>